package com.smart4j.framework.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;

/**
 * description: InvocationHandler 对 JDK动态代理进行，重构
 * @version v1.0
 * @author w
 * @param <T>
 * @date 2018年9月2日下午8:54:26
 *
 */
public class DynamicProxyRefactor<T> implements InvocationHandler {
	
	private T target ;
	
	public DynamicProxyRefactor(T target) {
		super();
		this.target = target;
	}

	@SuppressWarnings("unchecked")
	public T getProxy(){
		return (T) Proxy.newProxyInstance(target.getClass().getClassLoader(),
											target.getClass().getInterfaces(), this);
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.println("method name:"+method.getName());
		return method.invoke(target, args);
	}
	
	



}
